package com.sgb.contract.view.ui.details;

import androidx.lifecycle.MutableLiveData;

import com.sgb.contract.api.AbstractCallBack;
import com.sgb.contract.api.ContractNet;
import com.sgb.contract.base.viewmodel.BaseViewModel;
import com.sgb.contract.model.ApprovalLogBean;
import com.swgk.core.base.model.entity.BaseEntity;

import java.util.List;

import retrofit2.Call;

/**
 * 其他信息
 *
 * @author cyj
 */
public class OtherInfoViewModel extends BaseViewModel {

    /**
     * 是否显示审批日志布局
     */
    public MutableLiveData<List<ApprovalLogBean>> approvalLogBean = new MutableLiveData<>();

    /**
     * 合同审批日志
     */
    public void getContractApprovalLogList(String auditId) {
        showLoading();
        ContractNet.getInstance().getCapitalApi().contractApprovalLogList(auditId).enqueue(new AbstractCallBack<BaseEntity<List<ApprovalLogBean>>>() {
            @Override
            public void onSuccess(BaseEntity<List<ApprovalLogBean>> data) {
                if (null != data.getData() && data.getData().size() != 0) {
                    approvalLogBean.postValue(data.getData());
                } else {
                    approvalLogBean.postValue(null);
                }
            }

            @Override
            public void onFailure(Call call, Throwable t) {
                approvalLogBean.postValue(null);
            }
        });
    }
}
